#region Copyright
/// <copyright>
/// Copyright (c) 2007 Ilia Shramko.
/// Released under the terms of the GNU General Public License.
/// </copyright>
#endregion

using System;
using System.Collections.Generic;
using System.Text;

namespace Osh.Teletext
{
	public class BasicLevel1TeletextCoding
	{
		private Charset _defaultCharset;
		private Charset _secondCharset;

		public BasicLevel1TeletextCoding(EnhancementDataPacket packet)
		{
			int triplet1 = packet.GetTriplet(0);
			int triplet2 = packet.GetTriplet(1);

			int g0 = (triplet1 >> 10) & 0xF;
			int g2 = (triplet1 >> 7) & 0x7;
			_defaultCharset = new Charset((byte)((g0 << 3) | g2));
			
			g0 = ((triplet2 & 0x7) << 1) | ((triplet1 >> 17) & 0x1);
			g2 = (triplet1 >> 14) & 0x7;
			_secondCharset = new Charset((byte)((g0 << 3) | g2));
		}

		public Charset DefaultCharset
		{
			get { return _defaultCharset; }
		}

		public Charset SecondCharset
		{
			get { return _secondCharset; }
		}
	}
}
